package com.example.project.business.extendPoint.BeanFactoryPostProcessor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.stereotype.Component;

/**
* @author Hebojin
* @createTime 2023年2月27日 上午11:23:05
* @Description 类描述
*/

@Component
public class TestBeanDefinitionRegistryPostProcessor implements BeanDefinitionRegistryPostProcessor
{
    
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException
    {
        
        System.out.println("----TestBeanDefinitionRegistryPostProcessor------postProcessBeanFactory----------------");
        
    }
    
    @Override
    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException
    {
        System.out.println("----TestBeanDefinitionRegistryPostProcessor------postProcessBeanDefinitionRegistry----------------");
        // 先把serverA的def删除，再添加。 beanDefinitionNames里的顺序改变为 serviceB,serviceA，解决循环依赖问题
//        BeanDefinition beandefA = registry.getBeanDefinition("serviceA");
//        registry.removeBeanDefinition("serviceA");
//        registry.registerBeanDefinition("serviceA", beandefA);
    }
    
}
